﻿using System;
using System.Collections.Generic;
using System.Linq;  // for ToList, ToArray ...
using Microsoft.Extensions.Configuration;
using Microsoft.EntityFrameworkCore;
using CoworkspaceAdmin.Models;

namespace CoworkspaceAdmin.Controller
{
    interface IUserManager{
        User GetUser(string id);
        void RemoveUser(string id);
        List<User> GetAllUser();
    }

    public class UserManager : IUserManager
    {
        private readonly IConfiguration _config;
        Dictionary<string, User> users = new Dictionary<string, User>();
        public UserManager()
        {
        }

        public User GetUser(string id) {
            if (users.ContainsKey(id)){
                return users[id];
            }
            return null;
        }

        public void RemoveUser(string id) {
            if(users.ContainsKey(id)){
                users.Remove(id);
            }
        }

        public List<User> GetAllUser() {
            return users.Values.ToList();
        }
    }
}
